package net.xiduth.events.button;

import net.xiduth.events.ButtonEvent;
import net.xiduth.events.EventManager;
import net.xiduth.game.player.Player;
import net.xiduth.game.player.actions.Summoning;
import net.xiduth.game.player.content.SummoningScroll;
import net.xiduth.net.decoders.WorldPacketsDecoder;

public class SummoningCreationEvent implements ButtonEvent {

	@Override
	public boolean init() {
		EventManager.register(666, this);
		return EventManager.register(672, this);
	}

	@Override
	public boolean handle(Player player, int interfaceId, int buttonId,
			int packetId, int slotId, int slotId2) {
		if (interfaceId == 672) {
			switch(buttonId) {
			case 16:
				switch(packetId) {
				case WorldPacketsDecoder.ACTION_BUTTON1_PACKET:
					Summoning.createPouch(player, slotId2, 1);
					return true;
				case WorldPacketsDecoder.ACTION_BUTTON2_PACKET:
					Summoning.createPouch(player, slotId2, 5);
					return true;
				case WorldPacketsDecoder.ACTION_BUTTON3_PACKET:
					Summoning.createPouch(player, slotId2, 10);
					return true;
				}
			}
		} else {
			switch(buttonId) {
			case 16:
				switch(packetId) {
				case WorldPacketsDecoder.ACTION_BUTTON1_PACKET:
					SummoningScroll.createScroll(player, slotId2, 1);
					return true;
				case WorldPacketsDecoder.ACTION_BUTTON2_PACKET:
					SummoningScroll.createScroll(player, slotId2, 5);
					return true;
				case WorldPacketsDecoder.ACTION_BUTTON3_PACKET:
					SummoningScroll.createScroll(player, slotId2, 10);
					return true;
				}
			}
		}
		return false;
	}

}
